package com.example.demo.service;

import com.example.demo.bean.FileBean;
import com.example.demo.bean.GroupBean;
import com.example.demo.bean.StudentFileBean;
import com.example.demo.repository.FileRepository;
import com.example.demo.repository.GroupRepository;
import com.example.demo.repository.StudentFileRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;
import java.util.Map;

@Transactional
@Service
public class GroupService {

    @Autowired
    GroupRepository groupRepository;

    public GroupBean addGroup(GroupBean groupBean){
        return groupRepository.save(groupBean);
    }

    public Map<String, Object> findIsGroupBean(String cuserid){
        Map<String, Object> map = groupRepository.findGroupBeanById(cuserid);
        return map;
    }

    public String findCountBean(String groupid){
        String collection = groupRepository.findCountGroupBeanById(groupid);
        return collection;
    }


    public List<Map<String, Object>> findisGroupBean(String cuserid){
        List<Map<String, Object>> list = groupRepository.findisGroupById(cuserid);
        return list;
    }

    public void deleteGroup(String obj_id){
        groupRepository.deleteByObjId(obj_id);
    }

    public List<Map<String, Object>> findGroupBean(){
        List<Map<String, Object>> list = groupRepository.findGroup();
        return list;
    }


}
